<!--
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 14:41:20
 * @LastEditTime: 2023-07-19 15:16:17
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description:   :gridOps="gridOptions" 
-->
<template>
  <sc-VxeTable ref="xGrid1" :gridEvts="gridEvents" :tablecode="'pro_dyecraft'" :url="this.$API.pro.dyecraft.list">
  </sc-VxeTable>

  <save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSuccess" @closed="dialog.save = false">
  </save-dialog>
</template>
<script>

import SaveDialog from "./save";
export default {
  components: {
    SaveDialog,
  },
  name: "pro_dyecraft",
  data() {
    return {
      dialog: {
        save: false,
      },
      gridEvents: {
        cellDblclick: ({ row }) => {
          this.edit(row);
        },

        edit: () => {
          this.edit();
        },

      },
    };
  },
  methods: {
    openSave: function () {
      this.dialog.save = true;
      this.$nextTick(() => {
        this.$refs.saveDialog.open();
      });
    },

    handleSuccess() {
      this.$refs.xGrid1.refresh();
    },
    edit(item) {
      let selected = {};
      if (typeof item == "undefined") {
        let selects = this.$refs.xGrid1.xGrid.getCheckboxRecords();
        if (selects.length == 0) {
          this.$message.error("必须选中元素");
          return;
        } else {
          selected = selects[0];
        }
      } else selected = item;
      this.dialog.save = true;
      this.$nextTick(() => {
        this.$refs.saveDialog.open().setData(selected);
      });
    },
  },
};
</script>
